<?php
/**
 *	Architect Framework
 *
 *	Architect Framework is a light weight object oriented web applications framework written for PHP 5.1.4 and later that provide the tools to develop and deploy a website or application fast and with as little code as possible.
 *
 *	@author Robin Grass, <hello@coffinboy.se>
 *	@link http://architect.kodlabbet.net
 *	@license http://www.opensource.org/licenses/gpl-3.0.html GNU General Public License (v. 3)
 */

/**
 *	@const DIR_SEP Directory separator.
 */
define('DIR_SEP', DIRECTORY_SEPARATOR);

/**
 *	@const ARCH_ROOT_PATH Absolute path to Architect.
 */
define('ARCH_ROOT_PATH', dirname(__FILE__) . DIR_SEP);

/**
 *	Dynamically create constants from config.xml.
 */
$prefix = 'arch_';
$dom = DOMDocument::load(ARCH_ROOT_PATH . 'config.xml');
$xpath = new DOMXPath($dom);

foreach($xpath->query('//constant') as $constant) {

	$type = $constant->getAttribute('type');
	$name = strtoupper($prefix . $constant->getAttribute('name'));
	$value = $constant->nodeValue;

	if($type) {
		switch($type) {
			case 'path' :
				$value = ARCH_ROOT_PATH . $value;
				break;
			case 'bool' :
				$value = ($value == 'true' || $value == 1) ? true : false;
				break;
			default :
				$value = (string) $value;
			break;
		}
	}
define($name, $value);
}
?>